<template>
  <div class="etms-table-container">
    <div class="page-item" v-for="(item, index) in props.couponsInfo" :key="index">
      <div class="etms-coupons-body">
        <div class="etms-coupons-item-top"></div>
        <div class="etms-coupons-head">
          <div class="etms-coupons-condition">
            <div class="etms-coupons-condition-left">
              <span class="el-tag el-tag--warning el-tag--mini el-tag--plain">{{
                item.type
              }}</span>
              <div title="折扣" class="myTitle">{{ item.title }}</div>
            </div>
          </div>
          <div class="etms-coupons-value" style="clear: both">
            <div class="etms-coupons-unit">¥</div>
            <div class="etms-coupons-amount">{{ item.countMoney }}</div>
          </div>
          <div class="etms-coupons-middle-line">
            <div class="etms-coupons-circular left"></div>
            <div class="etms-coupons-circular right"></div>
          </div>
          <div class="etms-coupons-item-body">
            <div class="detailWrap">
              <div class="detail">
                <p>有效期：{{ item.effective }}</p>
                <p>{{ item.threshold }}</p>
                <p>&nbsp;</p>
                <p>总量：{{ item.num }} 已领取：0 已核销：0</p>
              </div>
            </div>
          </div>
          <div class="etms-coupons-item-op">
            <button
              type="button"
              class="el-button etms-coupons-item-op-button el-button--text el-button--mini"
            >
              <span>查看详情</span>
            </button>
            <div class="el-divider el-divider--vertical"></div>
            <button
              type="button"
              class="el-button etms-coupons-item-op-button el-button--text el-button--mini"
            >
              <span>标记失效</span>
            </button>
            <div class="el-divider el-divider--vertical"></div>
            <button
              type="button"
              class="el-button etms-coupons-item-op-button el-button--text el-button--mini"
            >
              <span @click="delCoupon(index)">删除</span>
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from "vue";
const props = defineProps(["couponsInfo"]);
const emits = defineEmits(["changeCoupons"]);
//删除
const delCoupon = (index) => {
  props.couponsInfo.splice(index, 1);
  emits("changeCoupons", props.couponsInfo);
};
</script>

<style lang="scss" scoped>
.etms-coupons-value {
  min-width: 60px;
  line-height: 23px;
  height: 23px;
  font-size: 0;
  padding-left: 20px;
  margin-bottom: 5px;
  color: #e6a23c;
}
.el-divider {
  margin-top: 5px;
  background-color: #ebeef5;
}
.el-divider--vertical {
  display: inline-block;
  width: 1px;
  height: 1em;
  margin: 0 8px;
  vertical-align: middle;
  position: relative;
}
.etms-coupons-item-op-button {
  padding: 0 !important;
  min-width: 0 !important;
  border: none !important;
}
.el-button--text {
  border-color: transparent;
  color: #1890ff;
  background: transparent;
}
.el-button--mini {
  font-size: 12px;
  border-radius: 3px;
}
.el-button {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid #dcdfe6;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  transition: 0.1s;
  font-weight: 400;
  -ms-user-select: none;
}
.etms-coupons-item-op {
  height: 30px;
  line-height: 30px;
  text-align: right;
  padding-right: 10px;
}
.detail {
  font-size: 12px;
  line-height: 20px;
  color: #666;
  position: absolute;
  top: 50%;
  -webkit-transform: translateY(-50%);
}
.detailWrap {
  height: 90px;
  position: relative;
}
.etms-coupons-item-body {
  padding-left: 20px;
  font-size: 12px;
  line-height: 20px;
  color: #666;
}
.etms-coupons-circular.left {
  left: -1px;
  border-left: none;
  border-radius: 0 9px 9px 0;
}
.etms-coupons-circular.right {
  right: -1px;
  border-right: none;
  border-radius: 9px 0 0 9px;
}
.etms-coupons-circular {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 17px;
  margin-top: -9px;
  border: 1px solid #e6ddda;
  background-color: #fff;
}
.etms-coupons-middle-line {
  position: relative;
  height: 0;
  font-size: 0;
  border-bottom: 1px dotted #d9d0cd;
}
.etms-coupons-unit {
  display: inline-block;
  font-size: 14px;
}
.etms-coupons-amount {
  display: inline-block;
  position: relative;
  left: 2px;
  bottom: 1px;
  font-weight: 700;
  font-size: 28px;
}
.myTitle {
  width: 210px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  display: inline-block;
  margin-left: 5px;
}
.el-tag--plain.el-tag--warning {
  background-color: #fff;
  border-color: #ffe399;
  color: #ffba00;
}
.etms-coupons-condition-left {
  float: left;
}
.etms-coupons-condition {
  padding-left: 20px;
  padding-top: 10px;
  height: 48px;
  display: table;
  vertical-align: middle;
  font-size: 14px;
  font-weight: 700;
  color: #666;
  word-break: break-all;
}
.etms-coupons-head {
  position: relative;
  color: #fff;
  zoom: 1;
}
.etms-coupons-item-top {
  height: 10px;
  background-color: #e6a23c;
}
.etms-coupons-body {
  position: relative;
  width: 298px;
  border: 1px solid #e6ddda;
  float: left;
}
.page-item {
  margin-right: 10px;
  padding: 10px;
}
</style>
